#pragma once

#include<cstdio>
#include<vector>
#include<stdlib.h>
#include<time.h>

typedef void(*task_t)();

void PrintLog()
{
    printf("我是一个打印日志任务\n");
}
void DownLoad()
{
    printf("我是一个下载任务\n");
}
void UpLoad()
{
    printf("我是一个上传任务\n");
}

class TaskManager
{
    public:
    TaskManager()
    {
        srand(time(nullptr));
    }
    ~TaskManager()
    {}
    void Register(task_t t)
    {
        _tasks.push_back(t);
    }
    int Code()
    {
        return rand() % _tasks.size();
    }
    void Excutive(int code)
    {
        if(code>=0 && code<_tasks.size())
        _tasks[code]();
    }
    private:
    std::vector<task_t> _tasks;

};